package com.itheima.com.service;

import com.itheima.com.Dao.StudentDao;
import com.itheima.com.domain.Student;

public class StudentService {
   private static StudentDao studentDao=new StudentDao();
    public static boolean isExits(String id) {
        Student[] students= StudentDao.getAllStudent();
        for (int i = 0; i < students.length; i++) {
           Student student= students[i];
           if (student!=null&&student.getId().equals(id)){
               return true;
           }
        }
        return false;
    }

    public static  void addStudent(Student stu) {
        StudentDao studentDao=new StudentDao();
        studentDao.addStudent(stu);
    }

    public static Student[] gatAllStudent() {
        return StudentDao.getAllStudent();
    }

    public static void deleteById(String did) {
        StudentDao.deleteById(did);
    }


    public static void updateStudent(String uid, Student newStu) {
        studentDao.updateStudent(uid,newStu);
    }
}
